package util;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.PrintWriter;

/**
 * User: bohao.wang
 * Date: 12-3-28
 * Time: 下午2:17
 */
public class FuncGen {
  /**
   * 修改Filein，Fileout即可
   * @param args .
   * @throws Exception .
   */
  public static void main(String[] args)
          throws Exception
  {
    String inFile = "src/res/extender.txt";
    String outFile = "func.txt";
    BufferedReader br = new BufferedReader(new FileReader(inFile));
    PrintWriter out = new PrintWriter(outFile);
    StringBuilder sb = new StringBuilder();
    int count = 0;
    String t;
    while((t = br.readLine()) != null)
      sb.append(t);
    br.close();
    for(int i = 0; i < sb.length(); ++i) {
      char ch = sb.charAt(i);
      if(ch == '[') {
        i += 3;
        String a = "";
        for(int j = 0; j < 4; ++j) {
          a += sb.charAt(i++);
        }
        i += 3;
        String b = "";
        for(int j = 0; j < 4; ++j) {
          b += sb.charAt(i++);
        }
        out.print(" inRange(c, '\\u" + a + "', '\\u" + b + "' ) || ");
        count++;
        if(count % 2 == 0)out.println("");
      }
      else if( ch == '#') {
        i += 2;
        String b = "";
        for(int j = 0; j < 4; ++j) {
          b += sb.charAt(i++);
        }
        out.print(" inRange(c, '\\u" + b + "', '\\u" + b + "' ) || ");
        count++;
        if(count % 2 == 0)out.println("");
      }
    }

    out.close();
  }
}
